﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StockFinder.Model
{
    public class TestTrade
    {
        public decimal BuyPrice { get; set; }
        public decimal SellPrice { get; set; }
        public DateTime BuyDate { get; set; }
        public DateTime SellDate { get; set; }

        /// <summary>
        /// Gets the % result of this trade
        /// </summary>
        /// <returns></returns>
        public decimal GetTradeResult()
        {
            return ((SellPrice - BuyPrice) / BuyPrice) * 100;
        }

        /// <summary>
        /// Gets the % result of this trade using a skid i.e. movement from close
        /// price to mimick bid/offer
        /// </summary>
        /// <returns></returns>
        public decimal GetTradeResult(decimal skid)
        {
            decimal buyPrice = BuyPrice + (BuyPrice * skid);
            decimal sellPrice = SellPrice - (SellPrice * skid);

            return ((sellPrice - buyPrice) / buyPrice) * 100;
        }

        public int GetLengthInDays()
        {
            return (SellDate - BuyDate).Days;
        }
    }
}
